const {
  createProxyMiddleware
} = require("http-proxy-middleware"); // 代理服务中间件

module.exports = function (app) {
  // 代理服务器地址

  const devProxyHost = process.env.REACT_APP_DEVELOPMENT_PROXY_PREFIX
  const prodBaseUrl = process.env.REACT_APP_PRODUCTION_URL

  app.use(
    createProxyMiddleware(devProxyHost, {
      target: `${prodBaseUrl}`,
      secure: false,
      changeOrigin: true,
      pathRewrite: {
        [`^${devProxyHost}`]: "",
      },
    })
  );

};